using System;
using System.Collections.Generic;

namespace SimpleCore
{
    public class ConvertTool
    {
        public static int StringToInt(string value)
        {
            int.TryParse(value, out var data);
            return data;
        }

        public static float StringToFloat(string value)
        {
            float.TryParse(value, out var data);
            return data;
        }
        
        public static bool StringToBool(string value)
        {
            bool.TryParse(value, out var data);
            return data;
        }
        
        public static List<int> StringToListInt(string value)
        {
            var result = new List<int>();
            
            value = value ?? "";
            var splits = value.Split('|');
            for (int i = 0; i < splits.Length; i++)
            {
                var temp = StringToInt(splits[i]);
                result.Add(temp);
            }

            return result;
        }
       
        public static List<float> StringToListFloat(string value)
        {
            var result = new List<float>();
            
            value = value ?? "";
            var splits = value.Split('|');
            for (int i = 0; i < splits.Length; i++)
            {
                var temp = StringToFloat(splits[i]);
                result.Add(temp);
            }

            return result;
        }
        
        public static List<bool> StringToListBool(string value)
        {
            var result = new List<bool>();
            value = value ?? "";
            
            var splits = value.Split('|');
            for (int i = 0; i < splits.Length; i++)
            {
                var temp = StringToBool(splits[i]);
                result.Add(temp);
            }

            return result;
        }

        public static List<string> StringToListString(string value)
        {
            var result = new List<string>();
            
            value = value ?? "";
            var splits = value.Split('|');
            for (int i = 0; i < splits.Length; i++)
            {
                result.Add(splits[i]);
            }

            return result;
        }
    }
}